package tw.edu.tku.im.maze;

import org.json.JSONException;
import org.json.JSONObject;

public class AddRoomReq extends ReqPacket {
   
   String room;
   String homeowner;
   int ticket;
   int mapLv;
   int mode;
   String roomPassword;
   
   //-------------------------------------------------------
   public AddRoomReq(String room, String homeowner, int ticket, int mapLv, 
                    int mode) 
   {
      this(room, homeowner, ticket, mapLv, mode, null);
   }
   
   public AddRoomReq(String room, String homeowner, int ticket, 
                    int mapLv, int mode, String roomPassword) {
      this.room = room;
      this.homeowner = homeowner;
      this.ticket = ticket;
      this.mapLv = mapLv;
      this.mode = mode;
      this.roomPassword = roomPassword;
   }
   
   //-------------------------------------------------------
   public String getRoom() {
      return this.room;
   }
   public void setRoom(String room) {
      this.room = room;
   }
   
   //-------------------------------------------------------
   public String getHomeowner() {
      return this.homeowner;
   }
   public void setHomeowner(String homeowner) {
      this.homeowner = homeowner;
   }
   
   //-------------------------------------------------------
   public int getTicket() {
      return this.ticket;
   }
   public void setTicket(int ticket) {
      this.ticket = ticket;
   }
   
   //-------------------------------------------------------
   public int getMapLv() {
      return this.mapLv;
   }
   public void setMapLv(int mapLv) {
      this.mapLv = mapLv;
   }
   
   //-------------------------------------------------------
   public int getMode() {
      return this.mode;
   }
   public void setMode(int mode) {
      this.mode = mode;
   }
   
   //-------------------------------------------------------
   public String getRoomPassword() {
      return this.roomPassword;
   }
   public void setRoomPassword(String roomPassword) {
      this.roomPassword = roomPassword;
   }
   
   //-------------------------------------------------------  
   public String toJSONString() throws JSONException {
      JSONObject parameter = new JSONObject();
      parameter.put("room", this.room);
      parameter.put("homeowner", this.homeowner);
      parameter.put("ticket", this.ticket);
      parameter.put("mapLv", this.mapLv);
      parameter.put("mode", this.mode);
      if(this.roomPassword!=null) {
         parameter.put("roomPassword", this.roomPassword);
      }
      JSONObject jsonObj = new JSONObject();
      jsonObj.put("parameter", parameter);
      jsonObj.put("action", "addRoom");
      return jsonObj.toString();
   }

   @Override
   public String getPacketName() {
      return "addRoom";
   }
  
}
